<template>
  <el-dialog title="查看历史参数数据" :visible="open" :before-close="onClose" append-to-body width="660px">
    <div v-loading="loading">
      <el-table :data="setList">
        <el-table-column type="index" width="55" align="center" />
        <el-table-column label="房间号码" align="center" prop="roomNo" />
        <el-table-column label="通讯状态" align="center" prop="runStatus">
          <template slot-scope="scope">
            <dict-tag :value="scope.row.runStatus" :options="dict.type.run_status" />
          </template>
        </el-table-column>
        <el-table-column label="系统时间" align="center" prop="updateDt" width="160">
          <template slot-scope="scope">{{ formatterDt(scope.row.updateDt) }}</template>
        </el-table-column>
        <el-table-column label="设备时间" align="center" prop="updateDt" width="160">
          <template slot-scope="scope">{{ formatterDt(scope.row.updateDt) }}</template>
        </el-table-column>
      </el-table>
    </div>
    <div slot="footer">
      <el-button size="small" @click="onClose">完成</el-button>
    </div>
  </el-dialog>
</template>

<script>
import RoomSelect from "@/components/RoomSelect.vue";
import { tmView } from "@/api/param/time";
import moment from 'moment';
export default {
  components: {
    RoomSelect
  },
  dicts: ["run_status"],
  data() {
    return {
      open: false,
      loading: false,
      setList: []
    };
  },
  methods: {
    formatterDt(date) {
      return moment(date).format("yyyy-MM-DD HH:mm:ss");
    },
    show(roomId) {
      this.open = true;
      tmView({roomId}).then(response => {
        this.setList = response.rows
      })
    },
    onClose() {
      this.open = false;
    }
  }
};
</script>